Repository navigation
Add front camera support for Surface Laptop 1/2 (OV9734) - #186
GuyliandeJong wants to merge 4 commits into
Conversation
|
First-generation Surface Laptop confirmation: the OV9734 front color camera works on a real SL1, using the three patches in linux-surface/linux-surface#2401. This is independent evidence for the hardware assumption in this PR. The two series are not identical, so this is not a Tested-by for
Two differences from the tested series matter when updating this PR to
The SL1 results used no new regulator requests; the optional GPIO/clock sequence is sufficient for this wiring. The regulator paths and timing differences in this PR still merit their own coverage. The working color variant also compiles on current Two suggested follow-ups on this exact PR head · 7.3 alternative with original attribution · fresh libcamera build and the separate single-stream 720p RFC. |
The ov9734 driver assumes the sensor is already powered by ACPI domain PM and never drives a reset line or enables its clock. On the Surface Laptop 1 and 2, the sensor (OVTI9734) is powered through a discrete INT3472 device (SKC1) which exposes a clock-enable GPIO, a reset GPIO and a privacy LED. Without toggling these, the sensor never answers on I2C. Request the optional "reset" GPIO and the avdd/dovdd/dvdd supplies, and add power on/off functions that enable the regulators and the clock and release the reset line. Power the sensor on before identifying it and hook the functions up as runtime PM callbacks. Tested on a Surface Laptop 2: the sensor is identified and streams via the IPU3 CIO2 and ImgU with libcamera. Signed-off-by: GuyliandeJong <109021171+GuyliandeJong@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Patchset: cameras
The front camera of the Surface Laptop 1 and 2 is an OmniVision OV9734 (ACPI HID OVTI9734), connected to CSI-2 port 1 of the IPU3 with one data lane. Without an entry in the supported sensor list, the bridge does not build the fwnode graph for it and the ov9734 driver fails to probe with "failed to check HW configuration: -6". Add the sensor with the 180 MHz link frequency required by the ov9734 driver. Tested on a Surface Laptop 2 together with the ov9734 power handling change: the bridge reports two connected cameras and the front camera streams with libcamera. Signed-off-by: GuyliandeJong <109021171+GuyliandeJong@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Patchset: cameras
On the Surface Laptop 2 the fwnode graph of the sensor is created by ipu-bridge, which can probe after the ov9734 driver. The driver then finds no endpoint, fails with -ENXIO and is never probed again, leaving the camera missing until the module is reloaded. This happened on about one boot in two. Return -EPROBE_DEFER when the endpoint is missing, as other sensor drivers used with ipu-bridge do, and report the error with dev_err_probe() so that deferral doesn't log an error. Signed-off-by: GuyliandeJong <109021171+GuyliandeJong@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DEFINE_RUNTIME_DEV_PM_OPS() also installs pm_runtime_force_suspend() and pm_runtime_force_resume() as system sleep callbacks. ipu3-cio2 already stops and restarts the sensor across system sleep through .s_stream(), and the two are not ordered against each other, so the sensor can be powered off while the bridge still uses it, or written to before it is powered on again. With a stream running across s2idle this ends in a failed register write (-121) on resume. Register the runtime PM callbacks only, as ov5693, ov7251 and ov8865 do. Reported-by: Sam <sammydirksz@gmail.com> Link: linux-surface/linux-surface#2401 Signed-off-by: GuyliandeJong <109021171+GuyliandeJong@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bdd5d11 to
ef23da9
Compare
|
Thanks for testing this on a real SL1. That confirms the SL1 has the same wiring as the SL2.
The PR is now rebased onto For context: Tin Posavec's upstream series "media: ov9734, ipu-bridge: Enable the camera on the Intel NUC M15" covers the same changes for mainline. Its ipu-bridge entry is already in media |
This adds front camera support for the Surface Laptop 2 (and, by the same ACPI layout, most likely the Surface Laptop 1). The feature matrix currently lists cameras as unsupported on both.
Hardware
From the DSDT of a Surface Laptop 2 (
Surface_Laptop_2_1769_Consumer):\_SB_.PCI0.I2C2.CAMF, HIDOVTI9734(OV9734), I2C address 0x36, with_DEPonSKC1SKC1is a discrete INT3472 with three GPIOs:0x78clock enable,0x4Dreset,0x16privacy LED. There is no power-enable GPIO.INT347E, OV7251) on link 2 behindSKC2already worked before this change.Changes
resetGPIO and theavdd/dovdd/dvddsupplies, powers the sensor on before identifying it, and uses the power functions as runtime PM callbacks.OVTI9734with the 180 MHz link frequency required by the driver. Without this, probing fails withfailed to check HW configuration: -6.Testing (Surface Laptop 2, 7.2.14-arch1-1-surface with these two modules rebuilt)
ov9734 2-0036is linked toipu3-csi2 1, and raw capture from the CIO2 gives correct 1296x734 SGRBG10 frames.camand via PipeWire. Tested at 320x240, 640x480, 1024x576 and 1280x704.Userspace note
libcamera 0.7.2 also needs changes before the camera is usable by apps. I plan to send these to libcamera upstream separately:
ov9734CameraSensorHelper (linear gain{1, 0, 0, 16}, black level 64 at 10 bits)testPatternMode_inCameraSensorLegacy/CameraSensorRaw. It is uninitialised, sostart()fails at random for sensors without a test pattern map.calculateBDSHeight(). For sensors shorter than 1080 lines it inverts thestd::clampbounds and aborts. Also cap the advertised viewfinder size to whatvalidate()actually allows.🤖 Generated with Claude Code